package practice;

import java.util.Scanner;

public class _20String01 {

    static int n,k;
    static String string;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        k = scanner.nextInt();
        string = scanner.next();
        scanner.close();

        int count1 = 0;
        for (int i = 0;i < string.length();i++){
            if (string.charAt(i) == '1'){
                count1++;
            }
        }

        int res = 0;
        if (count1 >= k){
            res = Math.max(res,n-count1+k);
        }else {
            res = Math.max(res,n-(k-count1)%2);
        }
        count1 = n - count1;
        k--;
        if (k >= 0){
            if (count1 >= k){
                res = Math.max(res,n-count1+k);
            }else {
                res = Math.max(res,n-(k-count1)%2);
            }
        }
        System.out.println(res);
    }
}
